#include "widgethelper.h"
#include <QAbstractButton>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QPlainTextEdit>



WidgetHelper::WidgetHelper()
{

}


bool WidgetHelper::setCurrentIndex(QComboBox* cmb, const QString& value)
{
    bool found = false;
    for (int i = 0; i < cmb->count(); i ++)
    {
        if (cmb->itemData(i).toString() == value)
        {
            cmb->setCurrentIndex(i);
            found = true;
            break;
        }
    }
    return found;
}

bool WidgetHelper::setCurrentIndex(QComboBox* cmb, int value)
{
    bool found = false;
    for (int i = 0; i < cmb->count(); i ++)
    {
        if (cmb->itemData(i).toInt() == value)
        {
            cmb->setCurrentIndex(i);
            found = true;
            break;
        }
    }
    return found;
}

void WidgetHelper::setText(QLineEdit* edit, int value)
{
    edit->setText(QString("%1").arg(value));
}

